********************************************************************************
********Internet Penetration and National Innovation Capacities: Evidence from Worldwide Panel Data Analysis***********************************
********************************************************************************

use dta_submit.dta, clear

******descritive statistics********

sum pat_uspt wdi_internetuse bb wdi_internetserv sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
    polity2 fh_fotpsc hf_efiscore propertyrights businessfreedom   /***table 1 descriptive statistics***/
	
******empirical results*****
xtset prov_cod year
set more off
local ind_var "lint2 yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade polity2 fh_fotpsc hf_efiscore "
corr `ind_var'
qui:reg l(0).lpat_uspt2 lint2, robust
est store ols1
qui:reg l(0).lpat_uspt2 `ind_var' , robust
est store ols2
qui:xtreg l(0).lpat_uspt2 `ind_var' i.year,fe robust
est store fe1
qui:xtreg l(0).lpat_uspt2 `ind_var' i.prov_cod##c.year,fe robust
est store fe2
qui:xtreg l(0/1).lpat_uspt2 `ind_var' i.year, fe robust
est store fe3
set more off
local ind_var "lint2 yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade polity2 fh_fotpsc hf_efiscore"
qui:xtreg l(0/1).lpat_uspt2 `ind_var' i.prov_cod##c.year , fe robust
est store fe4

outreg2 [ols1 ols2 fe1 fe2 fe3 fe4] using tab_2, word dec(3) replace  /***Table 2 Baseline results***/

set more off
xtset prov_cod year
local ind_var "L.lint2 "
xtreg l(0).lpat_uspt2 `ind_var' i.year , fe robust


set more off
local ind_var "L.lint2 yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade polity2 fh_fotpsc hf_efiscore"
qui:xtreg l(0).lpat_uspt2 `ind_var' i.year , fe robust
est store fe1

set more off
local ind_var "L.lint2  yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade polity2 fh_fotpsc hf_efiscore"
qui:xtreg l(0/1).lpat_uspt2 `ind_var' i.year , fe robust
est store fe2


set more off
xtset prov_cod year
local ind_var "lint2 lint2_sq "
xtreg l(0/1).lpat_uspt2 `ind_var' i.year , fe robust


set more off
local ind_var "lint2 lint2_sq yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade polity2 fh_fotpsc hf_efiscore"
qui:xtreg l(0).lpat_uspt2 `ind_var' i.year , fe robust
est store fe3

set more off
local ind_var "lint2 lint2_sq yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade polity2 fh_fotpsc hf_efiscore"
qui:xtreg l(0/1).lpat_uspt2 `ind_var' i.year , fe robust
est store fe4

outreg2 [fe1 fe2 fe3 fe4] using table_3, dec(3) word replace see  /***table 3 the lagged and nonlinear effect of the Internet penetration***/


 
*****dynamic panel models

xtset prov_cod year
set more off
local ind_var 
xtabond2 L(0/1).lpat_uspt2 L(0).lint2 yr_sch_ter sha_rd y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2 L(0).lint2 yr_sch_ter sha_rd, c lag(1 4)) iv(y_dum1-y_dum20, eq(level)) r /// 
		 two  nom artests(3) h(2)

est store gmm1
		 
xtset prov_cod year
set more off
local ind_var 
xtabond2 L(0/1).lpat_uspt2 L(0).lint2 yr_sch_ter sha_rd lpop_dnst urbaniz y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2 L(0).lint2 yr_sch_ter sha_rd lpop_dnst urbaniz, c lag(1 4)) iv(y_dum1-y_dum20, eq(level)) r /// 
		 two  nom artests(3) h(2)		 
est store gmm2
		 
		 
xtset prov_cod year
set more off
local ind_var 
xtabond2 L(0/1).lpat_uspt2 L(0).lint2 yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2 L(0).lint2 yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade, c lag(1 4)) iv(y_dum1-y_dum20, eq(level)) r /// 
		 two nom  artests(3) h(2)
		 
est store gmm3
		 
xtset prov_cod year
set more off
local ind_var " yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade polity2 fh_fotpsc hf_efiscore "
xtabond2 L(0/1).lpat_uspt2 L(0).lint2 `ind_var' y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2 L(0).lint2 (`ind_var'), c lag(1 4)) iv(y_dum1-y_dum20, eq(level)) r /// 
		 two nom  artests(3) h(2)
		 
est store gmm4

outreg2 [gmm*] using dpd_A, dec(3) word see replace   /***Table 4 panel (A)***/

xtset prov_cod year
set more off
local ind_var 
xtabond2 L(0/1).lpat_uspt2 L(1).lint2 yr_sch_ter sha_rd y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2 L(1).lint2 yr_sch_ter sha_rd, c lag(1 4)) iv(y_dum1-y_dum20, eq(level)) r /// 
		 two  nom artests(3) h(2)

est store gmm1
		 
xtset prov_cod year
set more off
local ind_var 
xtabond2 L(0/1).lpat_uspt2 L(1).lint2 yr_sch_ter sha_rd lpop_dnst urbaniz y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2 L(1).lint2 yr_sch_ter sha_rd lpop_dnst urbaniz, c lag(1 4)) iv(y_dum1-y_dum20, eq(level)) r /// 
		 two  nom artests(3) h(2)		 
est store gmm2
		 
		 
xtset prov_cod year
set more off
local ind_var 
xtabond2 L(0/1).lpat_uspt2 L(1).lint2 yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2 L(1).lint2 yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade, c lag(1 4)) iv(y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
		 
est store gmm3
		 
xtset prov_cod year
set more off
local ind_var " yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade polity2 fh_fotpsc hf_efiscore "
xtabond2 L(0/1).lpat_uspt2 L(1).lint2 `ind_var' y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2 L(1).lint2 (`ind_var'), c lag(1 4)) iv(y_dum1-y_dum20, eq(level)) r /// 
		 two  nom artests(3) h(2)
		 
est store gmm4		 

outreg2 [ gmm*] using dpd_B, word dec(3) replace /***Table 4 panel (B)****/


xtset prov_cod year
set more off
local ind_var 
xtabond2 L(0/1).lpat_uspt2 L(0).lint2 lint2_sq yr_sch_ter sha_rd y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2 L(0).lint2 lint2_sq yr_sch_ter sha_rd, c lag(1 4)) iv(y_dum1-y_dum20, eq(level)) r /// 
		 two  nom artests(3) h(2)

est store gmm1
		 
xtset prov_cod year
set more off
local ind_var 
xtabond2 L(0/1).lpat_uspt2 L(0).lint2 lint2_sq yr_sch_ter sha_rd lpop_dnst urbaniz y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2 L(0).lint2 lint2_sq yr_sch_ter sha_rd lpop_dnst urbaniz, c lag(1 4)) iv(y_dum1-y_dum20, eq(level)) r /// 
		 two  nom artests(3) h(2)		 
est store gmm2
		 
		 
xtset prov_cod year
set more off
local ind_var 
xtabond2 L(0/1).lpat_uspt2 L(0).lint2 lint2_sq yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2 L(0).lint2 lint2_sq yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade, c lag(1 4)) iv(y_dum1-y_dum20, eq(level)) r /// 
		 two  nom artests(3) h(2)
		 
est store gmm3
		 
xtset prov_cod year
set more off
local ind_var " yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade polity2 fh_fotpsc hf_efiscore "
xtabond2 L(0/1).lpat_uspt2 L(0).lint2 lint2_sq `ind_var' y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2 L(0).lint2 lint2_sq (`ind_var'), c lag(1 4)) iv(y_dum1-y_dum20, eq(level)) r /// 
		 two  nom artests(3) h(2)
		 
est store gmm4
outreg2 [ gmm*] using dpd_C, word dec(3) replace  /***Table 4 panel (C)***/

***********************************************************************************
****Robustness check with alternative measures**************************
**************************************************************************
********1. use scientific journal articles as dependent variable

set more off
xtset prov_cod year
local ind_var "lint2 yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade polity2 fh_fotpsc hf_efiscore "
qui:xtreg l(0).ljur_art `ind_var' i.year, fe robust
est store jur_fe

set more off
local ind_var "lint2"
xtabond2 L(0/1).ljur_art  `ind_var' y_dum1-y_dum20, /// 
         gmm( L(0/1).(ljur_art) `ind_var',  c lag(1 3)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
est store gmm1

set more off
local ind_var "lint2 yr_sch_ter sha_rd"
xtabond2 L(0/1).ljur_art  `ind_var' y_dum1-y_dum20, /// 
         gmm( L(0/1).(ljur_art) `ind_var',  c lag(1 3)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
est store gmm2		 
		 
set more off
local ind_var "lint2 yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade"
xtabond2 L(0/1).ljur_art  `ind_var' y_dum1-y_dum20, /// 
         gmm( L(0/1).(ljur_art) `ind_var',  c lag(1 3)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)

est store gmm3

set more off
local ind_var "lint2 yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade polity2 fh_fotpsc hf_efiscore "
xtabond2 L(0/1).ljur_art  `ind_var' y_dum1-y_dum20, /// 
         gmm( L(0/1).(ljur_art) `ind_var',  c lag(1 3)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
est store gmm4
		 
outreg2 [jur_fe gmm1 gmm2 gmm3 gmm4] using rob_B1, dec(3) word see replace  /***Table 5 panel (A)***/

set more off
xtset prov_cod year
local ind_var "L.lint2 yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade polity2 fh_fotpsc hf_efiscore "
xtreg l(0).ljur_art `ind_var'  i.year, fe robust
est store jur_fe

set more off
local ind_var "l.lint2"
xtabond2 L(0/1).ljur_art  `ind_var' y_dum1-y_dum20, /// 
         gmm( L(0/1).(ljur_art) `ind_var',  c lag(1 3)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
est store gmm1

set more off
local ind_var "l.lint2 yr_sch_ter sha_rd"
qui:xtabond2 L(0/1).ljur_art  `ind_var' y_dum1-y_dum20, /// 
         gmm( L(0/1).(ljur_art) `ind_var',  c lag(1 3)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
est store gmm2		 
		 
set more off
local ind_var "l.lint2 yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade"
xtabond2 L(0/1).ljur_art  `ind_var' y_dum1-y_dum20, /// 
         gmm( L(0/1).(ljur_art) `ind_var',  c lag(1 3)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)

est store gmm3

set more off
local ind_var "l.lint2 yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade polity2 fh_fotpsc hf_efiscore "
xtabond2 L(0/1).ljur_art  `ind_var' y_dum1-y_dum20, /// 
         gmm( L(0/1).(ljur_art) `ind_var',  c lag(1 3)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
est store gmm4
		 
outreg2 [jur_fe gmm1 gmm2 gmm3 gmm4] using rob_B2, dec(3) word see replace  /***Table 5 panel (B)***/
		 
set more off
xtset prov_cod year
local ind_var "lint2 lint2_sq yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade polity2 fh_fotpsc hf_efiscore "
xtreg l(0).ljur_art `ind_var'  i.year, fe robust
est store jur_fe

set more off
local ind_var "lint2 lint2_sq"
xtabond2 L(0/2).ljur_art  `ind_var' y_dum1-y_dum20, /// 
         gmm( L(0/2).(ljur_art) `ind_var',  c lag(1 4)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
est store gmm1

set more off
local ind_var "lint2 lint2_sq yr_sch_ter sha_rd"
xtabond2 L(0/2).ljur_art  `ind_var' y_dum1-y_dum20, /// 
         gmm( L(0/2).(ljur_art) `ind_var',  c lag(1 4)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
est store gmm2		 
		 
set more off
local ind_var "lint2 lint2_sq yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade"
qui:xtabond2 L(0/2).ljur_art  `ind_var' y_dum1-y_dum20, /// 
         gmm( L(0/2).(ljur_art) `ind_var',  c lag(1 4)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)

est store gmm3

set more off
local ind_var "lint2 lint2_sq yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade polity2 fh_fotpsc hf_efiscore "
qui:xtabond2 L(0/2).ljur_art  `ind_var' y_dum1-y_dum20, /// 
         gmm( L(0/2).(ljur_art) `ind_var',  c lag(1 4)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
est store gmm4
		 
outreg2 [jur_fe gmm1 gmm2 gmm3 gmm4] using rob_C, dec(3) word see replace  /***Table 5 panel (c)***/
				 


***2. use alternative internet penetration rate
set more off
xtset prov_cod year
local ind_var "lbb_int yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade polity2 fh_fotpsc hf_efiscore "
qui:xtreg l(0).lpat_uspt2 `ind_var' i.year, fe robust   /**fixed broadband subscriptions as internet penetration measures***/
est store r_fe1

set more off
local ind_var "lbb_int "
xtabond2 L(0/1).lpat_uspt2  `ind_var' y_dum1-y_dum20, /// 
         gmm(L.lpat_uspt2 `ind_var', c  lag(1 4)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
		 
est store gmm1

set more off
local ind_var "lbb_int yr_sch_ter sha_rd "
xtabond2 L(0/1).lpat_uspt2  `ind_var' y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2 `ind_var', c  lag(1 4)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
est store gmm2

set more off
local ind_var "lbb_int yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade"
xtabond2 L(0/1).lpat_uspt2  `ind_var' y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2 `ind_var', c  lag(1 4)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
est store gmm3

set more off
local ind_var "lbb_int yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade polity2 fh_fotpsc hf_efiscore "
xtabond2 L(0/1).lpat_uspt2  `ind_var' y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2 `ind_var', c  lag(1 4)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
est store gmm4

outreg2 [r_fe1 gmm1 gmm2 gmm3 gmm4] using rob_panel_2A, dec(3) word see replace  /***Table 6 panel A***/

local ind_var "L.lbb_int yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade polity2 fh_fotpsc hf_efiscore "
qui:xtreg l(0).lpat_uspt2 `ind_var' i.year, fe robust   /**fixed broadband subscriptions as internet penetration measures***/
est store r_fe2

set more off
local ind_var "l.lbb_int "
xtabond2 L(0/1).lpat_uspt2  `ind_var' y_dum1-y_dum20, /// 
         gmm(L.lpat_uspt2 `ind_var', c  lag(1 4)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
		 
est store gmm1

set more off
local ind_var "l.lbb_int yr_sch_ter sha_rd "
xtabond2 L(0/1).lpat_uspt2  `ind_var' y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2 `ind_var', c  lag(1 4)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
est store gmm2

set more off
local ind_var "l.lbb_int yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade"
xtabond2 L(0/1).lpat_uspt2  `ind_var' y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2 `ind_var', c  lag(1 4)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
est store gmm3

set more off
local ind_var "l.lbb_int yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade polity2 fh_fotpsc hf_efiscore "
xtabond2 L(0/1).lpat_uspt2  `ind_var' y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2 `ind_var', c  lag(1 4)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
est store gmm4

outreg2 [r_fe2 gmm1 gmm2 gmm3 gmm4] using rob_panel_2B, dec(3) word see replace  /***Table 6 panel B***/

set more off
local ind_var "lbb_int lbb_int_sq yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade polity2 fh_fotpsc  hf_efiscore"
xtreg l(0).lpat_uspt2 `ind_var' i.year , fe robust
est store r_fe3                   /****nolinear with fixed broadband measure***/

set more off
local ind_var "lbb_int lbb_int_sq"
xtabond2 L(0/1).lpat_uspt2  `ind_var' y_dum1-y_dum20, /// 
         gmm(L.lpat_uspt2 `ind_var', c  lag(1 4)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
		 
est store gmm1

set more off
local ind_var "lbb_int lbb_int_sq yr_sch_ter sha_rd "
xtabond2 L(0/1).lpat_uspt2  `ind_var' y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2 `ind_var', c  lag(1 4)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
est store gmm2

set more off
local ind_var "lbb_int lbb_int_sq yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade"
xtabond2 L(0/1).lpat_uspt2  `ind_var' y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2 `ind_var', c  lag(1 4)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
est store gmm3

set more off
local ind_var "lbb_int lbb_int_sq yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade polity2 fh_fotpsc hf_efiscore "
xtabond2 L(0/1).lpat_uspt2  `ind_var' y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2 `ind_var', c  lag(1 4)) iv( y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
est store gmm4

outreg2 [r_fe3 gmm1 gmm2 gmm3 gmm4] using rob_panel_2C, dec(3) word see replace  /***Table 6 panel C ***/
clear
			
********************************************************************************
******threshold effects model***************************************************
********************************************************************************

help xthreg

use thre_submit.dta,clear

***tests on the existence and the number of threshold
xtset prov_cod year
set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade  ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2)   ///
	   qx(lint2) trim(0.01 0.01) thnum(2) bs(200 200) vce(robust)  /***5% significant threshold effects***/

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade  ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2)   ///
	   qx(lint2) trim(0.05 0.05) thnum(2) bs(200 200) vce(robust)   /***5% significant threshold effects***/

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(sha_rd) trim(0.01 0.01 0.01) thnum(3) bs(0 200 200) vce(robust)  /*** 1% significant threshold effects***/

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(sha_rd) trim(0.05 0.05) thnum(2) bs(200 200) vce(robust)  /*** 1% significant threshold effects***/

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(yr_sch_ter) trim(0.01 0.01) thnum(2) bs(200 200) vce(robust)  /*** 1% significant threshold effects***/

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(yr_sch_ter) trim(0.05 0.05) thnum(2) bs(200 200) vce(robust)  /*** 1% significant threshold effects***/
	   
set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(urbaniz) trim(0.01 0.01) thnum(2) bs(200 200) vce(robust)  /*** 1% significant threshold effects***/

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(urbaniz) trim(0.05 0.05) thnum(2) bs(200 200) vce(robust)  /*** 1% significant threshold effects***/
	   
set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(lpop_dnst) trim(0.01 0.01) thnum(2) bs(200 200) vce(robust)  /*** 1% significant threshold effects***/

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(lpop_dnst) trim(0.05 0.05) thnum(2) bs(200 200)  vce(robust) /*** 1% significant threshold effects***/

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(wdi_trade) trim(0.01 0.01) thnum(2) bs(200 200) vce(robust)  /*** 1% significant threshold effects***/

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(wdi_trade) trim(0.05 0.05) thnum(2) bs(200 200)   /*** 1% significant threshold effects***/

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(fh_fotpsc) trim(0.01 0.01) thnum(2) bs(200 200)   /*** 1% significant threshold effects***/

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(fh_fotpsc) trim(0.05 0.05) thnum(2) bs(200 200)   /*** 1% significant threshold effects***/

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(hf_efiscore) trim(0.01 0.01) thnum(2) bs(200 200) vce(robust)  /*** 1% significant threshold effects***/

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(hf_efiscore) trim(0.05 0.05) thnum(2) bs(200 200) vce(robust)  /*** 1% significant threshold effects***/

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc propertyrights y_dum2-y_dum19, rx(lint2 )   ///
	   qx(propertyrights) trim(0.01 0.01) thnum(2) bs(200 200)  vce(robust) /*** 1% significant threshold effects***/

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc propertyrights y_dum2-y_dum19, rx(lint2 )   ///
	   qx(propertyrights) trim(0.05 0.05) thnum(2) bs(200 200) vce(robust)  /*** 1% significant threshold effects***/

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter  urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc businessfreedom y_dum2-y_dum19 , rx(lint2)   ///
	   qx(businessfreedom) trim(0.01 0.01) thnum(2) bs(200 200)vce(robust)

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter  urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc businessfreedom y_dum2-y_dum19 , rx(lint2)   ///
	   qx(businessfreedom) trim(0.05 0.05) thnum(2) bs(200 200) vce(robust)
/****above results are handly organized in Table 7*****/
	   
	   
****threshold effect estimation

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade  ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2)   ///
	   qx(lint2) trim(0.05) thnum(1) bs(200) vce(robust)  /***5% significant threshold effects***/
est store th1

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(sha_rd) trim(0.01) bs(200) vce(robust)  /*** 1% significant threshold effects***/
est store th21

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(sha_rd) trim(0.05) bs(200) vce(robust)  /*** 1% significant threshold effects***/
est store th22

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(yr_sch_ter) trim(0.01 0.01) thnum(2) bs(200 200) vce(robust)  /***5% significant***/
est store th31

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(yr_sch_ter) trim(0.05) bs(200) vce(robust)  /*** 1% significant threshold effects***/
est store th32

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(urbaniz) trim(0.01 0.01) thnum(2) bs(200 200) vce(robust)  /***5% significant***/
est store th41

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(urbaniz) thnum(1) trim(0.05) bs(200) vce(robust)  /***asymmetric threshold effects***/ 
est store th42

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(lpop_dnst) thnum(1) trim(0.05) bs(200) vce(robust)  /***asymmetric threshold effects***/ 
est store th_popden

set more off
xthreg lpat_uspt2 sha_rd yr_sch_ter urbaniz lpop_dnst wdi_trade ///
       polity2 fh_fotpsc hf_efiscore y_dum2-y_dum19, rx(lint2 )   ///
	   qx(fh_fotpsc) thnum(1) trim(0.01) bs(200) vce(robust)  /***asymmetric threshold effects***/ 
est store th5
	   
outreg2 [th1 th21 th22 th31 th32 th41 th42 th_popden th5] using tab8, dec(3) word replace  /***Table 8 ***/

***calculate the percentage of obs. in differnt regimes
sum lint2 if lint2<=0.068
di 9/1083 
sum lint2 if lint2>4.388
di 112/1083
sum sha_rd if sha_rd>2.22
di 181/1083
sum yr_sch_ter if yr_sch_ter>0.199
di 990/1083

sum yr_sch_ter if yr_sch_ter<0.144
di 41/1083
sum urbaniz if urbaniz<56.163
di 204/1083

sum urbaniz if urbaniz>98.279
di 22/1083

sum urbaniz if urbaniz>61.538
di 798/1083
sum lpop_dnst if lpop_dnst>4.156
di 732/1083
sum wdi_trad if wdi_trade>41.305
di 944/1083
sum fh_fotpsc if fh_fotpsc>55
di 230/1083
sum hf_efiscore if hf_efiscore>67.9
di 436/1083
sum lint2
sum propertyrights if propertyrights>20
di 1059/1083
sum businessfreedom if businessfreedom>73.2
di 390/1083

clear

*****Results at Table 9

use dta_submit.dta, clear
set more off

gen int_dem_int=bmr_dem*lint2

xtset prov_cod year
local ind_var "lint2 yr_sch_ter sha_rd  lpop_dnst urbaniz wdi_trade fh_fotpsc hf_efiscore "
xtreg lpat_uspt2 `ind_var' i.year if bmr_dem==0, fe robust
est store int_dem0

local ind_var "lint2 yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade fh_fotpsc hf_efiscore "
xtreg lpat_uspt2 `ind_var' i.year if bmr_dem==1,fe robust
est store int_dem1

local ind_var "lint2 int_dem_int bmr_dem yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade fh_fotpsc hf_efiscore "
xtreg lpat_uspt2 `ind_var' i.year, fe robust
est store int_dem2

xtset prov_cod year

set more off
local ind_var "lint2 int_poli_int polity2 yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade  fh_fotpsc hf_efiscore "
xtabond2 L(0/1).lpat_uspt2  `ind_var' y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2  (`ind_var'), c lag(1 4)) iv(y_dum1-y_dum20, eq(level)) r /// 
		 two  nom artests(3) h(2)
est store dyn_dem1

set more off
local ind_var "lint2 int_dem_int bmr_dem yr_sch_ter sha_rd lpop_dnst urbaniz wdi_trade fh_fotpsc hf_efiscore "
xtabond2 L(0/1).lpat_uspt2  `ind_var' y_dum1-y_dum20, /// 
         gmm( L.lpat_uspt2  (`ind_var'), c lag(1 4)) iv(y_dum1-y_dum20, eq(level)) r /// 
		 two nom artests(3) h(2)
est store dyn_dem2
outreg2 [int_dem0 int_dem1 int_dem2 dyn_dem1 dyn_dem2] using tab_dem, word dec(3) replace /****Table 9***/

	   
